package fr.uniscol.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import fr.uniscol.model.utilisateur.User;

public class Eleve extends User implements Serializable, DonneeUniscol {
	
	private AnneeScolaire anneeScolaire = null;
	
	private int numId = 0;
	
	private String nom = null;
	
	private String prenom = null;
	
	private Date dateNaissance = null;
	
	private String ine = null;
	
	private List<Scolarite> scolarites = null;
	
	private List<NotationEleve> notations = null;
	
	private List<Structure> structures = null;

	public Eleve() {
		super();
	}

	public Eleve(int numId, String nom, String prenom) {
		super();
		this.numId = numId;
		this.nom = nom;
		this.prenom = prenom;
	}

	public String getId(){
		return anneeScolaire.getId() + "-" + getNumId();
	}
	
	public void setId(String id){
	}
	
	public AnneeScolaire getAnneeScolaire() {
		return anneeScolaire;
	}

	public void setAnneeScolaire(AnneeScolaire anneeScolaire) {
		this.anneeScolaire = anneeScolaire;
		
		for(Scolarite s : getScolarites()){
			s.setPeriode(anneeScolaire.getPeriodeActive());
			
			for(Structure st : s.getStructures()){
				st.setAnneeScolaire(anneeScolaire);
			}
		}
	}

	public int getNumId() {
		return numId;
	}

	public void setNumId(int id) {
		this.numId = id;
	}

	public String getNom() {
		if(nom == null){
			nom = "";
		}
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		if(prenom == null){
			prenom = "";
		}
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public Date getDateNaissance() {
		return dateNaissance;
	}

	public void setDateNaissance(Date dateNaissance) {
		this.dateNaissance = dateNaissance;
	}

	public String getIne() {
		if(ine == null){
			ine = "";
		}
		return ine;
	}

	public void setIne(String ine) {
		this.ine = ine;
	}

	@Override
	public int hashCode() {
		return getNumId();
	}

	public List<Scolarite> getScolarites() {
		if(scolarites == null){
			scolarites = new ArrayList<Scolarite>();
		}
		return scolarites;
	}

	public void setScolarites(List<Scolarite> scolarites) {
		this.scolarites = scolarites;
	}

	public List<NotationEleve> getNotations() {
		if(notations == null){
			notations = new ArrayList<NotationEleve>();
		}
		return notations;
	}

	public void setNotations(List<NotationEleve> notations) {
		this.notations = notations;
	}

	public List<Structure> getStructures() {
		if(structures == null){
			structures = new ArrayList<Structure>();
		}
		return structures;
	}

	public void setStructures(List<Structure> structures) {
		this.structures = structures;
	}

	@Override
	public boolean equals(Object obj) {
		Eleve e = (Eleve)obj;
		return e.getNumId() == e.getNumId();
	}
}
